package com.ss.android.article.base.feature.message;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Parcel;
import android.support.design.a;
import android.text.style.URLSpan;
import android.view.View;
import com.bytedance.article.common.c.TTUtils;
import com.ss.android.newmedia.MediaAppData;

public class HttpURLSpan extends URLSpan {
    public HttpURLSpan(Parcel parcel) {
        super(parcel);
    }

    public HttpURLSpan(String url) {
        super(url);
    }

    public void onClick(View view) {
        String url = this.getURL();
        if(!a.isTextEmpty(url) && (TTUtils.isValidUrl(url))) {
            Context context = view.getContext();
            Class clazz = MediaAppData.provide().getBrowserActivityClass();
            if(clazz != null) {
                Intent intent = new Intent(context, clazz);
                intent.setData(Uri.parse(url));
                context.startActivity(intent);
            }
        }
    }
}

